package com.my.cloud.exp;

import com.my.cloud.resp.ResultData;
import com.my.cloud.resp.ReturnCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2024/3/7 18:56
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    
    @ExceptionHandler(RuntimeException.class)
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public ResultData<String> exception(Exception e){

        System.out.println("#########com in GlobalExceptionHandler ");
        log.error("全局异常信息：{}", e.getMessage(), e);
        
        
        return ResultData.failure(ReturnCodeEnum.RC500.getCode() , e.getMessage());
        
    }
    
}
